Jupyter at Bryn Mawr College |
|||
Public notebooks: /services/public/dblank / jupyter.cs / Examples |
Based on Python Notebook: http://nbviewer.ipython.org/gist/arsenovic/d44166390b50f9f15df3
Original data source: https://github.com/cmrivers/ebola
This version: Doug Blank, Bryn Mawr College Computer Science, Oct 27, 2014
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame.from_csv('https://raw.githubusercontent.com/cmrivers/ebola/master/country_timeseries.csv',
index_col=0)
df = df.sort_index()
df = df.fillna(method='bfill')
cases_titles = [k for k in df.columns if 'deaths' in k.lower()]
df.plot(y=cases_titles)
death_titles = [k for k in df.columns if 'deaths' in k.lower()]
df.plot(y=death_titles)
plt.legend()
df['total deaths'] = df[death_titles].sum(axis =1)
df.plot(y='total deaths',
title='Total Deaths in \n 2014 Ebola Outbreak')
plt.ylabel('Total Deaths')
import seaborn as sn
df['log total deaths'] = np.log10(df['total deaths'].values)
sn.lmplot('Day','log total deaths', df)
import statsmodels.formula.api as sm
ols = sm.OLS(df['Day'].values, df['log total deaths'].values)
ols.fit().summary()